import time

import win32com.client

from win10toast import ToastNotifier

# 初始化通知器
toaster = ToastNotifier()

# 设置通知的内容和标题
message = "Hello, this is a desktop notification!"
title = "Python Notification"

speaker = win32com.client.Dispatch("SAPI.SpVoice")

def speak(text):
    # print(speaker.GetVoices().Item(0).GetDescription())
    speaker.Speak(text)

last_line=476

with open("织田信长.txt", "r", encoding='utf_8') as f:
    # line = f.readline()
    line_num = 0
    for line in f:
        line_num = line_num + 1
        if line_num < last_line:
            continue
        text = line.rstrip()
        print(line_num, text)
        # 发送通知
        # toaster.show_toast(str(line_num), text,
        #                    duration=5,  # 显示时长，默认为5秒
        #                    threaded=True)  # 非阻塞模式
        speak(text)



